/*
 * rolloff_d.cpp
 *
 *  Created on: Apr 16, 2012
 *      Author: pickrell
 */


#include "CmdLine.h"
#include "HapMatrices.h"
using namespace std;


void printopts(){
	cout << "\n";
	cout << "Options:\n";
	cout << "-i [file name] input file name (with paths to haplotype files)\n";
	cout << "-o [file name] output file name\n";
	cout << "-p [file name] list of individuals and populations\n";
	cout << "-a [string] admixed population\n";
	cout << "-s [string] source population\n";
	cout << "\n";
}

string infile, outfile, popfile, mixpop, sourcepop;
double by = 0.001;
double maxdist = 0.4;
bool freq = false;
int main(int argc, char *argv[]){

    CCmdLine cmdline;
    if (cmdline.SplitLine(argc, argv) < 1){
    	printopts();
    	exit(1);
    }
    if (cmdline.HasSwitch("-i")) infile = cmdline.GetArgument("-i", 0);
    else{
    	printopts();
    	exit(1);
    }
    if (cmdline.HasSwitch("-o")) outfile = cmdline.GetArgument("-o", 0);
    else{
    	printopts();
    	exit(1);
    }
    if (cmdline.HasSwitch("-p")) popfile = cmdline.GetArgument("-p", 0);
     else{
     	printopts();
     	exit(1);
     }
    if (cmdline.HasSwitch("-a")) mixpop = cmdline.GetArgument("-a", 0);
    else{
    	printopts();
      	exit(1);
    }
    if (cmdline.HasSwitch("-s")) sourcepop = cmdline.GetArgument("-s", 0);
    else{
    	printopts();
    	exit(1);
    }
    if (cmdline.HasSwitch("-max")) maxdist = atof(cmdline.GetArgument("-max", 0).c_str());
    if (cmdline.HasSwitch("-freq")) freq = true;
    HapMatrices d(infile, popfile, mixpop, sourcepop);
    d.MAXDIST = maxdist;
    if (!freq) d.roll_print_lowmem(outfile, by);
    else d.roll_print_freq_cor_lowmem(outfile, by);
    return 0;
}

